export function downloadFile(response, window, callBack) {
    let data = response.data;
    let json = null;
    if (data.type === "application/json") {
        data.text().then(text => {
            json = window.JSON.parse(text);
            callBack(json.msg);
        }).catch(() => json = null)
    } else {
        let url = window.URL.createObjectURL(new window.Blob([data]));
        let link = window.document.createElement("a");
        link.style.display = "none";
        link.href = url;
        let filename = response.headers["content-disposition"].split(
            "fileName="
        )[1];

        link.setAttribute("download", decodeURI(filename));
        window.document.body.appendChild(link);
        link.click();
        return null;
    }
}